package com.hxd.otc.module.convenience.presenter;

import android.support.annotation.NonNull;

import com.hxd.otc.base.BaseBean;
import com.hxd.otc.module.convenience.bean.ConvenienceOrderBean;
import com.hxd.otc.module.convenience.contract.ConvenienceOrderDetailContract;
import com.hxd.otc.module.convenience.model.ConvenienceModel;
import com.hxd.otc.mvp.base.BasePresenter;
import com.hxd.otc.net.BaseObserver;

/**
 * Created by lzy on 2019/1/18 0018.
 * description ${便民订单详情Presenter}
 */
public class ConvenienceOrderDetailPresenter extends BasePresenter<ConvenienceOrderDetailContract.IView> implements ConvenienceOrderDetailContract.IPresenter {

    private final ConvenienceModel mConvenienceModel;

    public ConvenienceOrderDetailPresenter(ConvenienceOrderDetailContract.IView iView) {
        super(iView);
        mConvenienceModel = ConvenienceModel.getInstance();
    }

    @Override
    public void requestOrderDetail(String orderId) {
        mConvenienceModel.getOrderDetail(orderId, new BaseObserver<ConvenienceOrderBean>() {
            @Override
            public void onNext(@NonNull String msg, @NonNull ConvenienceOrderBean convenienceOrderData) {
                mView.getOrderDetailSuccess(convenienceOrderData);
            }

            @Override
            public void onError(int errType, @NonNull String errMessage) {
                mView.showToast(errMessage);
            }
        }, mView.<BaseBean<ConvenienceOrderBean>>bindAutoDispose());
    }
}
